cmake_minimum_required(VERSION 3.0.0)

set(MODULE_NAME "GtkUtils")
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
    set(${MODULE_NAME}_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/include")
    set(${MODULE_NAME}_LIBRARIES ${MODULE_NAME})
else()
    set(${MODULE_NAME}_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE)
    set(${MODULE_NAME}_LIBRARIES ${MODULE_NAME} PARENT_SCOPE)
endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})

include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)

find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 gtk+-3.0)
pkg_check_modules(GTK4 gtk4)

add_library(${MODULE_NAME}
    "src/GtkUtils.c"
)

if(GTK3_FOUND)
    link_directories(${GTK3_LIBRARY_DIRS})
    target_include_directories(${MODULE_NAME} PUBLIC ${GTK3_INCLUDE_DIRS})
    target_link_libraries(${MODULE_NAME} ${GTK3_LIBRARIES})
endif()

if(GTK4_FOUND)
    link_directories(${GTK4_LIBRARY_DIRS})
    target_include_directories(${MODULE_NAME} PUBLIC ${GTK4_INCLUDE_DIRS})
    target_link_libraries(${MODULE_NAME} ${GTK4_LIBRARIES})
endif()

# add_subdirectory(lib/GtkUtils)
# target_include_directories(${MODULE_NAME} PRIVATE
#     ${GtkUtils_INCLUDE_DIRS}
# )
# target_link_libraries(${MODULE_NAME}
#     ${GtkUtils_LIBRARIES}
# )

# GtkUtils Test
option(ENABLE_GTKUTILS_TEST "Enable building GtkUtils test" ON)
if(ENABLE_GTKUTILS_TEST)
    # add_subdirectory(test/)
endif(ENABLE_GTKUTILS_TEST)